var request = require('../../utils/request.js')
var app = getApp();
Page({
  data: {
    pocketlist: null,
    cardlist:null,
    mini_app_user:null,
    mobile:'',
    discountslist:[]
  },
  enter: function (e) {
    my.navigateTo({
      url: e.currentTarget.id
    })
  },
  // 优惠券
  coupon: function() {
    my.navigateTo({
      url: '/pages/myWallet/coupon'
    })
  },
  //绑定手机号
  bindphone() {
    my.navigateTo({
      url: '/pages/user/mobile',
    })
  },
  //获取页面数据
  getuserinfo() {
    let success = (res) => {
      console.log(res)
      if (res.discounts){
        this.setData({
          discountslist:res.discounts
        })
      }
      this.setData({
        mini_app_user:res.mini_app_user,
        pocketlist: res.pocket,
        cardlist: res.charge_card,
        mobile:res.telephone
      })
    }
    request.getdata("/users/user/show", {}, success, this);
  },
   //开通月卡
  getcardbtn: function(){
    my.navigateTo({
      url: '/pages/myWallet/renew',
    })
  },
  onShow: function () {
    my.getNetworkType({
      success: (res) => {
        if(!res.networkAvailable||res.networkType=='UNKNOWN'){
          my.showToast({
            content: '网络状态不佳，请检查网络',
            type:'fail',
            duration: 2000
          })
        }
      }
    })
    // var success = (data) =>{
       this.getuserinfo()
    // }
    // request.postdata('/Pay/getAliInfo', {}, success, this)
  },
  onLoad: function () {
  },


})
